<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.4.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"ckyhahaha.info","root":"/","scheme":"Gemini","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.xml"};
  </script>

  <meta name="description" content="七层模型1.实体层​          物理手段把电脑链接起来，负责发送0和1电信号 2.链接层​          (1)以太网协议(数据包的定义)​                 一组电信号构成一个数据包，叫做帧，一帧分为head和data​          (2)mac地址​                一块网卡有一个mac地址，也数据包的发送和接收地址​          (3)广播">
<meta property="og:type" content="article">
<meta property="og:title" content="http七层模型和https">
<meta property="og:url" content="https://ckyhahaha.info/2022/01/21/http%E4%B8%83%E5%B1%82%E6%A8%A1%E5%9E%8B%E5%92%8Chttps/index.html">
<meta property="og:site_name" content="cky小站">
<meta property="og:description" content="七层模型1.实体层​          物理手段把电脑链接起来，负责发送0和1电信号 2.链接层​          (1)以太网协议(数据包的定义)​                 一组电信号构成一个数据包，叫做帧，一帧分为head和data​          (2)mac地址​                一块网卡有一个mac地址，也数据包的发送和接收地址​          (3)广播">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://ckyhahaha.info/2022/01/21/http%E4%B8%83%E5%B1%82%E6%A8%A1%E5%9E%8B%E5%92%8Chttps/1349955143-5acd61d83d0d4_fix732.png">
<meta property="og:image" content="https://ckyhahaha.info/2022/01/21/http%E4%B8%83%E5%B1%82%E6%A8%A1%E5%9E%8B%E5%92%8Chttps/3654006606-5acd70ff081e8_fix732.png">
<meta property="article:published_time" content="2022-01-21T07:11:21.000Z">
<meta property="article:modified_time" content="2022-01-21T07:17:54.109Z">
<meta property="article:author" content="cky">
<meta property="article:tag" content="http">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://ckyhahaha.info/2022/01/21/http%E4%B8%83%E5%B1%82%E6%A8%A1%E5%9E%8B%E5%92%8Chttps/1349955143-5acd61d83d0d4_fix732.png">

<link rel="canonical" href="https://ckyhahaha.info/2022/01/21/http%E4%B8%83%E5%B1%82%E6%A8%A1%E5%9E%8B%E5%92%8Chttps/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>http七层模型和https | cky小站</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

<link rel="alternate" href="/atom.xml" title="cky小站" type="application/atom+xml">
</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">cky小站</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">记录学习知识和生活中的点点滴滴</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/about" rel="section"><i class="fa fa-user fa-fw"></i>关于</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags" rel="section"><i class="fa fa-tags fa-fw"></i>标签<span class="badge">4</span></a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories" rel="section"><i class="fa fa-th fa-fw"></i>分类<span class="badge">4</span></a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives" rel="section"><i class="fa fa-archive fa-fw"></i>归档<span class="badge">4</span></a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result">
  <div id="no-result">
    <i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
  </div>
</div>

    </div>
  </div>

</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://ckyhahaha.info/2022/01/21/http%E4%B8%83%E5%B1%82%E6%A8%A1%E5%9E%8B%E5%92%8Chttps/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.jpg">
      <meta itemprop="name" content="cky">
      <meta itemprop="description" content="相见恨晚">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="cky小站">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          http七层模型和https
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>
              

              <time title="创建时间：2022-01-21 15:11:21 / 修改时间：15:17:54" itemprop="dateCreated datePublished" datetime="2022-01-21T15:11:21+08:00">2022-01-21</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/http/" itemprop="url" rel="index"><span itemprop="name">http</span></a>
                </span>
            </span>

          
            <span class="post-meta-item" title="阅读次数" id="busuanzi_container_page_pv" style="display: none;">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span id="busuanzi_value_page_pv"></span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h2 id="七层模型"><a href="#七层模型" class="headerlink" title="七层模型"></a>七层模型</h2><h4 id="1-实体层"><a href="#1-实体层" class="headerlink" title="1.实体层"></a>1.实体层</h4><p>​          物理手段把电脑链接起来，负责发送0和1电信号</p>
<h4 id="2-链接层"><a href="#2-链接层" class="headerlink" title="2.链接层"></a>2.链接层</h4><p>​          (1)以太网协议(数据包的定义)<br>​                 一组电信号构成一个数据包，叫做帧，一帧分为head和data<br>​          (2)mac地址<br>​                一块网卡有一个mac地址，也数据包的发送和接收地址<br>​          (3)广播<br>​               向所有计算机发送数据包，计算机与数据包head的接收mac地址相比较，相同就接受这个包。</p>
<span id="more"></span>

<h4 id="3-网络层"><a href="#3-网络层" class="headerlink" title="3.网络层"></a>3.网络层</h4><p>​          (1)互联网由无数子网络组成，以太网只能在同一个子网络发送数据包，网络地址能确定计算机所在的子网络<br>​          (2)ip协议<br>​               每台计算机分配一个ip，确定那些在同一子网络。<br>​          (3)ip数据包<br>​               以太协议上的data中，加上ip的head<br>​          (4)APR协议<br>​               同一个子网络，查询ip地址得到对方的mac地址</p>
<h4 id="4-传输层"><a href="#4-传输层" class="headerlink" title="4.传输层"></a>4.传输层</h4><p>​           (1)一台主机不同的程序用不同的网络，不同的端口来区分，0-1023是系统端口，主机+端口就是socket<br>​           (2)UDP协议(无法确认收到数据)<br>​                在ip的数据包中放上head<br>​           (3)TCP协议(有确认机制)<br>​                近似有确认机制的udp协议，数据确保不会遗失，实现过程复杂。</p>
<h4 id="5-会话层："><a href="#5-会话层：" class="headerlink" title="5.会话层："></a>5.会话层：</h4><p>会话层负责在网络中的两节点之间建立和维持通信，并保持会话获得同步，它还决定通信是否被中断以及通信中断时决定从何处重新发送。</p>
<h4 id="6-表示层-："><a href="#6-表示层-：" class="headerlink" title="6.表示层 ："></a>6.表示层 ：</h4><p>表示层的作用是管理数据的解密与加密，如常见的系统口令处理，当你的账户数据在发送前被加密，在网络的另一端，表示层将对接收到的数据解密。另外，表示层还需对图片和文件格式信息进行解码和编码。</p>
<h4 id="7-应用层"><a href="#7-应用层" class="headerlink" title="7.应用层"></a>7.应用层</h4><p>​          规定应用程序的数据格式，放在tcp的数据包中</p>
<p><img src="/2022/01/21/http%E4%B8%83%E5%B1%82%E6%A8%A1%E5%9E%8B%E5%92%8Chttps/1349955143-5acd61d83d0d4_fix732.png" alt="1349955143-5acd61d83d0d4_fix732"></p>
<h2 id="常见状态码"><a href="#常见状态码" class="headerlink" title="常见状态码"></a>常见状态码</h2><p>200:请求成功</p>
<p>404:请求的资源不存在</p>
<p>503:服务器超时</p>
<p>304:自从上次请求后，内容未修改在缓存中</p>
<p>102:服务端处理请求，无响应可以用<br>202:请求收到，但未响应<br>300:提供一系列地址让客户重定向<br>301:永久重定向<br>302:临时重定向<br>400:请求语义或参数有误，不应重复请求<br>401:请求需身份验证或验证失败<br>403:对被请求的页面访问被禁止<br>405:不允许的请求方法<br>500:服务端报错<br>502:无效网关<br>505:请求的http协议版。本不被支持</p>
<h2 id="https-用端口443-ssl层简称安全套阶层"><a href="#https-用端口443-ssl层简称安全套阶层" class="headerlink" title="https(用端口443.ssl层简称安全套阶层)"></a>https(用端口443.ssl层简称安全套阶层)</h2><p><img src="/2022/01/21/http%E4%B8%83%E5%B1%82%E6%A8%A1%E5%9E%8B%E5%92%8Chttps/3654006606-5acd70ff081e8_fix732.png" alt="3654006606-5acd70ff081e8_fix732"></p>
<ol>
<li>服务器端产生的是对称秘钥，所以只是把公钥发送出去，私钥一直在自己这里 （对称秘钥就是一个公钥，一个私钥，用公钥加密，用私钥直接能解码，但是比较慢，不能一直用这个通信）</li>
<li>客户端首先向一个权威的服务器检查证书的合法性，如果证书合法，客户端产生一段随机数，这个随机数就作为通信的密钥，我们称之为对称密钥，用公钥加密这段随机数，然后发送到服务器</li>
<li>服务器用密钥解密获取对称密钥，然后，双方就已对称密钥进行加密解密通信了</li>
</ol>

    </div>

    
    
    
        

  <div class="followme">
    <p>欢迎关注我的其它发布渠道</p>

    <div class="social-list">

        <div class="social-item">
          <a target="_blank" class="social-link" href="/atom.xml">
            <span class="icon">
              <i class="fa fa-rss"></i>
            </span>

            <span class="label">RSS</span>
          </a>
        </div>
    </div>
  </div>


      <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/http/" rel="tag"># http</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item"></div>
      <div class="post-nav-item">
    <a href="/2022/01/21/text/" rel="next" title="迷吊灯灯又一天">
      迷吊灯灯又一天 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E4%B8%83%E5%B1%82%E6%A8%A1%E5%9E%8B"><span class="nav-number">1.</span> <span class="nav-text">七层模型</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#1-%E5%AE%9E%E4%BD%93%E5%B1%82"><span class="nav-number">1.0.1.</span> <span class="nav-text">1.实体层</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#2-%E9%93%BE%E6%8E%A5%E5%B1%82"><span class="nav-number">1.0.2.</span> <span class="nav-text">2.链接层</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#3-%E7%BD%91%E7%BB%9C%E5%B1%82"><span class="nav-number">1.0.3.</span> <span class="nav-text">3.网络层</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#4-%E4%BC%A0%E8%BE%93%E5%B1%82"><span class="nav-number">1.0.4.</span> <span class="nav-text">4.传输层</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#5-%E4%BC%9A%E8%AF%9D%E5%B1%82%EF%BC%9A"><span class="nav-number">1.0.5.</span> <span class="nav-text">5.会话层：</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#6-%E8%A1%A8%E7%A4%BA%E5%B1%82-%EF%BC%9A"><span class="nav-number">1.0.6.</span> <span class="nav-text">6.表示层 ：</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#7-%E5%BA%94%E7%94%A8%E5%B1%82"><span class="nav-number">1.0.7.</span> <span class="nav-text">7.应用层</span></a></li></ol></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%B8%B8%E8%A7%81%E7%8A%B6%E6%80%81%E7%A0%81"><span class="nav-number">2.</span> <span class="nav-text">常见状态码</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#https-%E7%94%A8%E7%AB%AF%E5%8F%A3443-ssl%E5%B1%82%E7%AE%80%E7%A7%B0%E5%AE%89%E5%85%A8%E5%A5%97%E9%98%B6%E5%B1%82"><span class="nav-number">3.</span> <span class="nav-text">https(用端口443.ssl层简称安全套阶层)</span></a></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="cky"
      src="/images/avatar.jpg">
  <p class="site-author-name" itemprop="name">cky</p>
  <div class="site-description" itemprop="description">相见恨晚</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives">
        
          <span class="site-state-item-count">4</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories">
          
        <span class="site-state-item-count">4</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags">
          
        <span class="site-state-item-count">4</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        
  <div class="beian"><a href="https://beian.miit.gov.cn/" rel="noopener" target="_blank">粤ICP备2021147162号-1 </a>
  </div>

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2022</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">cky</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Gemini</a> 强力驱动
  </div>

        
<div class="busuanzi-count">
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    <span class="post-meta-item" id="busuanzi_container_site_uv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-user"></i>
      </span>
      <span class="site-uv" title="总访客量">
        <span id="busuanzi_value_site_uv"></span>
      </span>
    </span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item" id="busuanzi_container_site_pv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-eye"></i>
      </span>
      <span class="site-pv" title="总访问量">
        <span id="busuanzi_value_site_pv"></span>
      </span>
    </span>
</div>








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/pisces.js"></script>


<script src="/js/next-boot.js"></script>




  




  
<script src="/js/local-search.js"></script>













  

  

</body>
</html>
